package cn.simon.service;

import cn.simon.mapper.CommentMapper;
import cn.simon.model.Comment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CommentService {
    @Autowired
    private CommentMapper commentMapper;
    public int addComment(Comment comment){

        return commentMapper.insert(comment);
    }

    /**
     * 管理员操作
     * @param id
     * @return
     */
    public int deleteByCommentId(Integer id){
        return commentMapper.deleteById(id);
    }

    /**
     * 根据商品ID查看买家评论
     * @param id
     * @return
     */
    public List<Comment> findByGoodsId(Integer id){
        return commentMapper.selectByGoodsId(id);
    }
    public Comment findByCommentId(Integer id){
        return commentMapper.selectById(id);
    }
    public Comment updateByCommentId(Integer id) {
        return commentMapper.updateByCommentId(id);
    }

    public Comment selectById(int id){
        return commentMapper.selectById(id);
    }

}
